﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Xioa_UI.Controls;
using Xioa_UI.Domain;
using Xioa_UI.Message;
using Xioa_UI.Service;

namespace Xioa_UI_Demo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : XioaWindow
    {
        public MainWindow()
        {
            //AutomationCarryOut.Run<string>("temp1");
            this.SettingHeightWidthAdaptationScreenPrimary();
            this.ItemIcon = new BitmapImage(new Uri("/assets/logo.png", UriKind.Relative));
            this.DataContext = new CheckBoxGroupViewModel();
            InitializeComponent();
            // WindowMoveSizeChange.WindowChangeHelper.WindowStateNormalAction += null;
            WindowMoveSizeChange.MainWindowChangeHelper.AddWindowStateMaximizedAction("key",
                () => { Console.WriteLine("Max Method"); });
            WindowMoveSizeChange.MainWindowChangeHelper.AddWindowStateNormalAction("key",
                () => { Console.WriteLine("Normal Method"); });
        }

        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
        }

        private void btn_Click(object sender, RoutedEventArgs e)
        {
            //var xioaWindow = new XioaFalgWindow();
            //xioaWindow.Show();
        }

        private void XioaButton_Click(object sender, RoutedEventArgs e)
        {
            var result = XioaMessageBox.Show(this, "MessageMessageMessage\n" +
                                                   "MessageMessageMessageMessageMessageMessageMessageMessage\n" +
                                                   "MessageMessageMessageMessageMessageMessageMessageMessage\n" +
                                                   "MessageMessageMessageMessageMessageMessageMessageMessage\n",
                "Xioa1", XioaMessageBoxButton.YesNoCancel,
                XioaMessageBoxButtonText.CreateXioaMessageBoxButtonText("确认", "取消", "退出"));
        }

        private void TcpSendClick(object sender, RoutedEventArgs e)
        {
            tcpBorder.Send("Hello World !");
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            Application.Current.Shutdown();
            base.OnClosing(e);
        }

        private void TcpAcceptClick(object sender, RoutedEventArgs e)
        {
            var data = XioaTcpDataContent.GetValue("xioa");
            XioaMessageBox.Show(data);
        }

        private void XioaButton_Click_1(object sender, RoutedEventArgs e)
        {
            var window = new ComeCapture.MainWindow();
            window.Closed += (_, args) =>
            {
                var image = Clipboard.GetImage();
                if (image is null) return;
                var imageBrowser = new XioaImageBrowser(image);
                imageBrowser.Show();
            };
            window.Show();
        }


        private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            WindowMoveSizeChange.MainWindowChangeHelper.WindowMove_MouseButtonDown(sender, e, this);
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            PrintDialog view = new PrintDialog();
            view.ShowDialog();
            //view.PrintVisual(XioaBorder, "打印报告");
        }

        private void XioaSearchBar_TextChanged(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(search.Text);
        }

        private void XioaSearchBar_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine();
        }

        private void XioaPageHeaderControl_Click(object sender, RoutedEventArgs e)
        {

        }
        
        
   
        private void Masks_Click(object sender, RoutedEventArgs e)
        {
            XioaMasks.Loading(() =>
            {
                Thread.Sleep(6000);
            });
        }
    }
}